Skip to content

Run the before-publish build only in the publish run - #244

Merged
vgpopov merged 3 commits into
v4from
fix/before-publish-build-main-only-v4
Nov 11, 2026
Merged

vgpopov merged 3 commits into
v4from
fix/before-publish-build-main-only-v4

Conversation

@vgpopov

@vgpopov vgpopov commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Problem

Run build (before publish) in node-simple-pnpm.yaml has no condition. It runs on pull_request, merge_group, and the main run that commits the version bump. A block passes build-before-publish-script-name: build:release, which is the default of the block-tools template since platforma 83298ed6a7. Since MILAB-6497, block-tools software build uploads the binaries in that build when PL_BUILD_LOCATION=remote. Before that, the upload ran in prepublishOnly, only at npm publish.

PR runs also apply changeset version, so a PR run uploads the binaries of the next release version. When the PR changes its bump or closes, that version stays in the registry. The release that later gets the version finds the file. package-builder-lib core.ts logs already exists … Upload was skipped, and the step stays green. The release then ships the old binaries.

Incident: clonotype-clustering 4.3.0

Run What happened
PR #156, run 39406490270 (Oct 20) The first push had software: minor. The run computed 4.2.1 → 4.3.0 and uploaded …/4.3.0.tgz with the 4.2.x scripts. The PR then switched to patch and released 4.2.2.
PR #163, run 42624024397 (Nov 9) software: minor gave 4.2.3 → 4.3.0. Turbo cache miss: the build ran, and all four uploads were skipped as already exists.
Merge queue and main runs Turbo replayed that task (d25cdc827d826de1), and the release shipped descriptors for the old files.

The process-results/4.3.0.tgz on bin.pl-open.science has file dates of Oct 20 12:44 CEST, and its content is identical to 4.2.3. clonotype-clustering#164 worked around it with 4.3.1.

Change

The step now uses the condition of Pack unpublished npm packages:

if: github.ref_name == 'main'
  && steps.check-changes.outputs.has-changes == '0'
Run Run build (build-script-name) Run build (before publish)
pull_request runs skipped
merge_group (gh-readonly-queue/…) runs skipped
push main, version bump pending (has-changes == '1') runs skipped; the bot commits the bump
push main, nothing to bump (has-changes == '0') runs runs, then pack and publish

Tradeoff

PR runs no longer run the release-channel build. A failure that only build:release shows appears first on main. build-script-name (build:dev-local for blocks) still builds the whole workspace on every PR.

Not in this PR

  • Registry slots already taken by earlier PR runs stay. Each one is a trap for a later release of the same version.
  • block-tools run-build.ts does not pass failExisting for the release channel, so a taken slot is a warning and not an error.

Check

actionlint reports no new findings: the same 20 findings as v4, all from earlier code.

The step had no condition, so it ran on pull_request, merge_group, and
the main run that commits the version bump. A block passes build:release
here, and block-tools software build uploads binaries in that build.
A PR run with a changeset version uploads the binaries of a version that
is not released yet. When the PR changes its bump, that version stays in
the registry. The later release finds the file, skips the upload with a
warning, and ships the old binaries.

clonotype-clustering: PR #156 run 39406490270 uploaded software 4.3.0
from 4.2.1 code. Release 4.3.0 (PR #163) skipped the upload and shipped
those files.

Use the condition of the npm pack step: main, with no version-bump
changes left.
@greptile-apps

greptile-apps Bot commented Nov 11, 2026

Copy link
Copy Markdown

Automatic reviews are disabled for this repository. Configure in Code Review Settings.

@vgpopov

vgpopov commented Nov 11, 2026

Copy link
Copy Markdown
Contributor Author

How the if works

- name: Run build (before publish)
  if: github.ref_name == 'main'
    && steps.check-changes.outputs.has-changes == '0'

The step runs only when both parts are true.

  1. github.ref_name == 'main' keeps out PR and merge-queue runs.
    • On pull_request, ref_name is <number>/merge, for example 163/merge.
    • On merge_group, ref_name is gh-readonly-queue/main/pr-163-….
    • Only a push to main, or a manual run on main, gives main.
  2. steps.check-changes.outputs.has-changes == '0' keeps out the run that commits the version bump.
    • check-changes runs only on a push to main, after changeset version, and looks for changed files.
    • '1' means changesets changed versions. This run commits "Auto-generated changes" and pushes, and that push starts a new run.
    • '0' means there was nothing to bump. This run is the publication run.
    • If check-changes did not run (PR, merge queue, manual run), its output is an empty string. '' == '0' is false, so the step is skipped.
push / pull_request / merge_group
        │
        ▼
Run changeset version            versions in the workspace go up (also on PRs)
        │
        ▼
check-changes                    only on push to main
        │                        '1' = bump pending, '0' = nothing to bump, '' = did not run
        ▼
Run build (build:dev-local)      every run, nothing uploaded
        │
        ▼
Run tests
        │
        ▼
Run build (before publish)       + if: ref_name == 'main' && has-changes == '0'
        │
        ├─ PR (163/merge)               → skipped: no upload
        ├─ merge queue (gh-readonly-…)  → skipped: no upload
        ├─ main, has-changes '1'        → skipped; the bot commits the bump → new run
        └─ main, has-changes '0'        → build:release uploads binaries
                                          → Pack unpublished npm packages (same if) → publish

The binary upload and the npm pack now run under the same condition. Binaries upload only in the run that publishes that version, as prepublishOnly: pl-pkg prepublish did before MILAB-6497.

A workflow_dispatch run on main now skips this step. It never published before either, because Pack unpublished npm packages already has the same condition.

@DenKoren DenKoren left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check this scenario, please, if not yet:

  • build happens in worker 1. It creates package but does not upload it.
  • turbo cache uploads cached files into remote storage
  • the next step (publish) gets cache hit, puts files from cache to disk and skips the build process: no package archives are on disk and nothing to upload.
  • publish step tries to ensure packages are on remote side, they are not and there is no local archive to upload == failure.

On the ubuntu-26.04 runner image 20261101, apt cannot resolve the Ubuntu
archive hosts, and the Install bats step fails. The npm registry resolves
on the same runner. The npm package has the same version, 1.13.0, that
apt installed on image 20261025.
@vgpopov
vgpopov merged commit a912cf0 into v4 Nov 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants